import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/user/Login',
    method: 'post',
    data
  })
}

export function getInfo(token) {
  return request({
    url: '/user/select?userId=' + 'admin',
    method: 'get'
  })
}

export function logout() {
  return request({
    url: '/user/logout',
    method: 'get'
  })
}

export function getAllUser() {
  return request({
    url: 'user/selectAll',
    method: 'get'
  })
}

export function updateUser(user_id, user_pwd) {
  return request({
    url: 'user/changePwd?user_id=' + user_id + '&user_pwd=' + user_pwd,
    method: 'put'
  })
}

export function updateUserStatus(userId, userPwd, userStatus, userType, userOldStatus) {
  return request({
    url: 'user/banManagerUser?userId=' + userId + '&userPwd=' + userPwd + '&userStatus=' + userStatus + '&userType=' + userType + '&userOldStatus=' + userOldStatus,
    method: 'put'
  })
}

export function addUser(userId, userClassName, userEmail, userLevel, userName, userOrigin, userPartName, userPhone, userSex, userOldStatus, userPwd, userStatus, userType) {
  console.log('传过来的userOldStatus为', userOldStatus)
  return request({
    url: 'user/addManagerUser?userId=' + userId + '&userInfo.userClassName=' + userClassName + '&userInfo.userEmail=' + userEmail + '&userInfo.userId=' + userId + '&userInfo.userLevel=' + userLevel + '&userInfo.userName=' + userName + '&userInfo.userOrigin=' + userOrigin + '&userInfo.userPartName=' + userPartName + '&userInfo.userPhone=' + userPhone + '&userInfo.userSex=' + userSex + '&userOldStatus=2' + '&userPwd=' + userPwd + '&userStatus=' + userStatus + '&userType=' + userType,
    method: 'post'
  })
}
